package com.lecloud.api.connect;

import java.io.File;
import java.util.Map;

import cn.edu.live.util.TimeUtil;

import com.alibaba.fastjson.JSONObject;
import com.lecloud.constant.Const;
import com.lecloud.model.PublicParam;
import com.lecloud.util.FileUploader;
import com.lecloud.util.LeCloudVerify;

/**
 * 直播活动封面上传接口（ver=4.0）
 * 
 * @author zhagz
 * 
 */
public class ModifyCoverImage {

	private static final String modifyCover_method = "lecloud.cloudlive.activity.modifyCoverImg";
	private static final String modifyCover_ver = "4.0";

	public JSONObject modifyCover(String activityId, File file) {
		Map<String, String> map = PublicParam.getPublicParamMap(modifyCover_method, modifyCover_ver, Const.userid,
				TimeUtil.currentTime());
		map.put("activityId", activityId);

		String sign = LeCloudVerify.getSign(map);
		map.put("sign", sign);
		JSONObject js = new FileUploader().doUpload(Const.common_url, map, file);

		return js;
	}

	public static void main(String[] args) {
		String activityId = "A2017032000000l4";
		File f = new File("G:\\Pictures\\Camera Roll\\36da4a4fb10ba963239ccb9a54a1cb63.jpg");
		JSONObject js = new ModifyCoverImage().modifyCover(activityId, f);
		System.out.println(js.toJSONString());
	}
}
